<%--
   Dict Selector
   Copyright (c) 2013 ISPERP
   Version : 1.0.0
 --%>
<%@tag import="itsm.isperp.module.entity.app.AppDict"%>
<%@tag import="java.util.List"%>
<%@tag import="itsm.isperp.framework.core.context.ContextHolder"%>
<%@tag import="itsm.isperp.module.service.app.AppDictService"%>
<%@ tag language="java" pageEncoding="UTF-8"
	deferredSyntaxAllowedAsLiteral="false" trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ attribute name="id" required="true" type="java.lang.String"
	description="唯一标识."%>
<%@ attribute name="name" required="false" type="java.lang.String"
	description="name"%>
<%@ attribute name="items" required="false" type="java.util.List"
	description="items"%>

<%@ attribute name="selectedValue" required="false"
	type="java.lang.String" description="selectedValue"%>

<%@ attribute name="onchangeFunc" required="false"
	type="java.lang.String" description="onchangeFunc"%>

<%@ attribute name="otherAttribute" required="false"
	type="java.lang.String" description="otherAttribute"%>
<%@ attribute name="hasEmptyValue" required="false"
	type="java.lang.Boolean" description="hasEmptyValue"%>

<c:set var="hasEmptyValue"
	value="${empty hasEmptyValue?true:hasEmptyValue }"></c:set>
 
 <c:set var="areReadonly"
	value="${empty areReadonly?false:areReadonly }"></c:set>
 
<jsp:doBody />

<select id="${id }" name="${name }" onchange="${onchangeFunc }"
	data-allow-empty="${hasEmptyValue }" ${otherAttribute }>
	<%
		for (Object o : items) {
		AppDict dict=(AppDict)o;
	%>
	<option value="<%=dict.getName()%>" data-code="<%=dict.getCode()%>"
		<%if(dict.getName().equals(selectedValue)){%> selected="selected"
		<%}%>><%=dict.getName()%></option>
	<%
		}
	%>
</select>
